package com.bocai.kelala.ui.travel.set.ada;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bocai.kelala.R;
import com.bocai.kelala.bean.AddressListBean;
import com.bocai.kelala.ui.travel.set.act.AddAddressActivity;
import com.bocai.mybase.base.BaseRecyclerAdapter;
import com.bocai.mybase.base.BaseRecyclerViewHolder;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.http.Body;

/**
 * Created by zhelun on 2017/3/8.
 */

public class AddressAda extends BaseRecyclerAdapter<AddressListBean.AddressesBean> {


    @Override
    public void showData(BaseRecyclerViewHolder viewHolder, final int i, final List<AddressListBean.AddressesBean> mItemDataList) {
        Log.e("showData","showData"+i);
        ViewHolder viewHolder1 = (ViewHolder) viewHolder;
        viewHolder1.tvReceiptName.setText(mItemDataList.get(i).getContacts());
        viewHolder1.tvReceiptAddress.setText(mItemDataList.get(i).getRegionName()+mItemDataList.get(i).getAddress());
        viewHolder1.tvReceiptPhone.setText(mItemDataList.get(i).getPhone());
        if (mItemDataList.get(i).isIsDefault()){
            viewHolder1.imgCheck.setImageDrawable(getContext().getResources().getDrawable(R.mipmap.check_add_invoice_select));
        }else{
            viewHolder1.imgCheck.setImageDrawable(getContext().getResources().getDrawable(R.mipmap.check_add_invoice_unselect));
        }
        viewHolder1.llEdit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getContext(), AddAddressActivity.class);
                intent.putExtra("index",1);
                intent.putExtra("data",mItemDataList.get(i));
                getContext().startActivity(intent);
            }
        });
    }

    @Override
    public int getListLayoutId() {
        return R.layout.item_address;
    }

    @Override
    public ViewHolder createViewHolder(View view) {
        return new ViewHolder(view);
    }

    class ViewHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.tv_receipt_name)
        TextView tvReceiptName;
        @BindView(R.id.tv_receipt_phone)
        TextView tvReceiptPhone;
        @BindView(R.id.tv_receipt_address)
        TextView tvReceiptAddress;
        @BindView(R.id.ll_edit)
        LinearLayout llEdit;
        @BindView(R.id.img_check)
        ImageView imgCheck;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }


    }
}
